/*
 * BaseView.java
 *
 * Created on Jul 6, 2009, 10:41:35 AM
 */

package it309.rms.view;

import java.awt.Component;
import java.awt.Container;
import java.awt.ScrollPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;

/**
 *
 * @author khangdt
 */
public class BaseView extends javax.swing.JPanel {

    
    /** Creates new form BaseView */
    public BaseView() {
        initComponents();
    }

    //private JViewport parentPanel;

    /** To Change content of the mainPanel in the Main screen */
    public void show(Component com, JViewport parentPanel){
        parentPanel.removeAll();
        parentPanel.add(com);
    }

    /** To Change content of the mainPanel in the Main screen */
    public void show(Component com){
        show(com, (JViewport)this.getParent());
    }

    /** To Change content of the mainPanel in the AdminMainView*/
    public void setComponent(Component com) {
        setComponent(com, (JPanel)this.getParent());
        //this.validate();
    }

    /** To Change content of the mainPanel in the AdminMainView*/
    public void setComponent(Component com, JPanel parentCom){
        parentCom.removeAll();
        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(parentCom);
        parentCom.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(com, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(com, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        //com.requestFocus();
    }

    /** To show the default screen of Admin*/
    public void setDefaultAdminComponent(){
        setComponent(new SearchEmployeeView());
    }

    /** To show the default screen of Employee*/
    public void setDefaultEmployeeComponent(){
        setComponent(new SearchResourceView());
    }

    public void exit(){
        System.exit(1);
    }

    public void showErrorMessage(String msg){
        JOptionPane.showMessageDialog(this, msg,"Error Message",JOptionPane.ERROR_MESSAGE);
    }

    public void showMessage(String msg, int msgType){
        JOptionPane.showMessageDialog(this, msg,"Error Message", msgType);
    }

    public void showInformMessage(String msg){
        JOptionPane.showMessageDialog(this, msg,"Information Message",JOptionPane.INFORMATION_MESSAGE);
    }

    public void showWarningMessage(String msg){
        JOptionPane.showMessageDialog(this, msg,"Information Message",JOptionPane.WARNING_MESSAGE);
    }

    public int showConfirmMessage(String msg){
        return JOptionPane.showConfirmDialog(this, msg, "Confirm Message", JOptionPane.INFORMATION_MESSAGE);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
